#include "PrecompiledHeaderRenderer_OpenGL.h"
#include "DepthWrapper.h"

/*--------------------------------------------------------------------------*/
GLboolean DepthWrapper::_DepthMask = GL_TRUE;
GLboolean DepthWrapper::_DepthTest = GL_TRUE;
GLenum DepthWrapper::_DepthFunc = GL_LEQUAL;
/*--------------------------------------------------------------------------*/

DepthWrapper::DepthWrapper()
{
	glDepthMask(_DepthMask);

	if (_DepthTest)
	{
		glEnable(GL_DEPTH_TEST);
	}
	else
	{
		glDisable(GL_DEPTH_TEST);
	}

	glDepthFunc(_DepthFunc);
}

/*--------------------------------------------------------------------------*/

DepthWrapper::~DepthWrapper()
{

}

/*--------------------------------------------------------------------------*/

void DepthWrapper::DepthMask(GLboolean v1)
{
	if (v1 != _DepthMask)
	{
		_DepthMask = v1;
		glDepthMask(_DepthMask);
	}
}

/*--------------------------------------------------------------------------*/

void DepthWrapper::DepthTest(GLboolean v1)
{
	if (v1 != _DepthTest)
	{
		_DepthTest = v1;

		if (v1)
		{
			glEnable(GL_DEPTH_TEST);
		}
		else
		{
			glDisable(GL_DEPTH_TEST);
		}
	}
}

/*--------------------------------------------------------------------------*/

void DepthWrapper::DepthFunc(GLenum f)
{
	if (f != _DepthFunc)
	{
		_DepthFunc = f;
		glDepthFunc(_DepthFunc);
	}
}

/*--------------------------------------------------------------------------*/